import pyqtgraph as pg
import pyqtgraph.opengl as gl
import numpy as np

# 创建应用程序
app = pg.mkQApp()

# 创建一个3D视图窗口
view = gl.GLViewWidget()
view.setBackgroundColor('w')  # 'w' 代表白色
view.show()


gx = gl.GLGridItem()
gx.rotate(90, 0, 1, 0)
gx.translate(-10, 0, 0)
gx.setColor((0, 0, 255,70))
view.addItem(gx)
gy = gl.GLGridItem()
gy.rotate(90, 1, 0, 0)
gy.translate(0, -10, 0)
gy.setColor((0, 0, 255,70))
view.addItem(gy)
gz = gl.GLGridItem()
gz.translate(0, 0, -10)
gz.setColor((0, 0, 255,70))
view.addItem(gz)
# 设置窗口的大小和标题
view.setWindowTitle('3D Points')
view.setFixedSize(800, 600)
axisitem = gl.GLAxisItem()
view.addItem(axisitem)
# 创建一个散点图项目并添加到视图中
points = np.array([[1, 0, 0]])  # 原点坐标
scatter = gl.GLScatterPlotItem(pos=points, size=10, color=(1,0,0,1))  # 红色点，大小为10
scatter.setGLOptions('opaque')  # 确保点在背景前可见
view.addItem(scatter)

# 启动应用程序
if __name__ == '__main__':
    pg.exec()
